<template>
 <div>

<el-descriptions title="问卷详情浏览表" :column="2" border :extra="'浏览用户：' + user.username">
    <el-descriptions-item label="所属机构">北华航天工业学院</el-descriptions-item>
    <el-descriptions-item label="任务名称"> {{taskDTO.task.taskName}}</el-descriptions-item>
    <el-descriptions-item label="任务类型"> {{taskDTO.task.type}}</el-descriptions-item>
    <el-descriptions-item label="创建时间"> {{taskDTO.task.createTime}}</el-descriptions-item>
    <el-descriptions-item label="结束时间"> {{taskDTO.task.endTime}}</el-descriptions-item>
    <el-descriptions-item v-if="taskDTO.task.type === '评估，评价问卷'" label="评估，评价问卷类型"> {{taskDTO.evaluate.type}}</el-descriptions-item>
    <el-descriptions-item v-if="taskDTO.task.type === '调查问卷'" label="调查问卷类型"> {{taskDTO.investigation.type}}</el-descriptions-item>
</el-descriptions>

<el-descriptions title="问卷详情" border :column="1"   v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师对学生的评价'">
    <el-descriptions-item label="学生是否积极响应老师问题" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师对学生的评价'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="学生有无迟到现象" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师对学生的评价'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="学生有无早退现象" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师对学生的评价'"
    >
    <span v-if="options[2] !== '还未填写'">
    {{options[2]}}
    </span>
    <span v-if="options[2] === '还未填写'">
        <el-input v-model="contents[2]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="学生是否能够按时完成课余任务" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师对学生的评价'"
    >
    <span v-if="options[3] !== '还未填写'">
    {{options[3]}}
    </span>
    <span v-if="options[3] === '还未填写'">
        <el-input v-model="contents[3]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>



<el-descriptions title="问卷详情" border :column="1"   v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师自评'"
>
    <el-descriptions-item label="您认为学生学习状态如何" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师自评'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为学生学习效果如何" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师自评'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为您教学质量如何" label-width="200px"
         v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师自评'"
    >
    <span v-if="options[2] !== '还未填写'">
    {{options[2]}}
    </span>
    <span v-if="options[2] === '还未填写'">
        <el-input v-model="contents[2]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="学生是否能够按时完成课余任务" label-width="200px"
          v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教师自评'"
    >
    <span v-if="options[3] !== '还未填写'">
    {{options[3]}}
    </span>
    <span v-if="options[3] === '还未填写'">
        <el-input v-model="contents[3]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>



<el-descriptions title="问卷详情" border :column="1" v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '课程评价'"
>
    <el-descriptions-item label="您认为此课程开启意义如何" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '课程评价'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为此课程教师讲解是否生动" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '课程评价'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为此课程是否对自己有帮助" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '课程评价'"
    >
    <span v-if="options[2] !== '还未填写'">
    {{options[2]}}
    </span>
    <span v-if="options[2] === '还未填写'">
        <el-input v-model="contents[2]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>

<el-descriptions title="问卷详情" border :column="1"
 v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教学评价'"
>
    <el-descriptions-item label="老师教学情况是否符合自己的需要" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教学评价'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为学生学习效果如何" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教学评价'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="您认为您教学质量如何" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '教学评价'"
    >
    <span v-if="options[2] !== '还未填写'">
    {{options[2]}}
    </span>
    <span v-if="options[2] === '还未填写'">
        <el-input v-model="contents[2]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>


<el-descriptions title="问卷详情" border :column="1"
  v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '听课评估'"
>
    <el-descriptions-item label="学生是否积极响应老师问题" label-width="200px"
        v-if="taskDTO.task.type === '老师授课时，学生的整体状态如何' && taskDTO.evaluate.type === '听课评估'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="是否有学生上课违规" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '听课评估'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="老师是否对知识存在偏差" label-width="200px"
        v-if="taskDTO.task.type === '评估，评价问卷' && taskDTO.evaluate.type === '听课评估'"
    >
    <span v-if="options[2] !== '还未填写'">
    {{options[2]}}
    </span>
    <span v-if="options[2] === '还未填写'">
        <el-input v-model="contents[2]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>



<el-descriptions title="问卷详情" border :column="1"    v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给学生，调查'">
    <el-descriptions-item label="调查标题" label-width="200px"
       v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给学生，调查'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="调查内容" label-width="200px"
        v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给学生，调查'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>


<el-descriptions title="问卷详情" border :column="1"   v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给老师，问题反馈'">
    <el-descriptions-item label="你想反馈的标题" label-width="200px"
        v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给老师，问题反馈'"
    >
    <span v-if="options[0] !== '还未填写'">
    {{options[0]}}
    </span>
    <span v-if="options[0] === '还未填写'">
        <el-input v-model="contents[0]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
    <el-descriptions-item label="你想反馈的内容" label-width="200px"
        v-if="taskDTO.task.type === '调查问卷' && taskDTO.investigation.type === '给老师，问题反馈'"
    >
    <span v-if="options[1] !== '还未填写'">
    {{options[1]}}
    </span>
    <span v-if="options[1] === '还未填写'">
        <el-input v-model="contents[1]" autocomplete="off"></el-input>
    </span>
    </el-descriptions-item>
</el-descriptions>
<el-button v-if="options[0]==='还未填写'" type="primary" style="position:relative;top:10px;" @click="put()">提交</el-button>




 </div>
</template>
<script>
export default {
  // 创建了一个组件，组件的名字为name
  name: 'Home',
  data () {
    return {
      options: ['还未填写','还未填写','还未填写','还未填写','还未填写','还未填写','还未填写','还未填写'],
      contents: [],
      user: {},
      role: '',
      taskDTO: {
          task: {
              taskName: '',
              type: '',
              createTime: '',
              endTime: '',
              
          },
          evaluate: {
              taskName: '',
              type: '',
              content: ''
          },
          investigation: {
              taskName: '',
              type: '',
              content: ''
          },
          option: ''
      },
    }
  },
  created () {
      const id = window.sessionStorage.getItem('task_id')
      this.user = JSON.parse(window.sessionStorage.getItem('user'))
      this.$http.get('/task/' + id).then(response => {
          this.taskDTO = response.data
          if(this.taskDTO.task.type === '评估，评价问卷' && this.taskDTO.evaluate.content!=="") {
              this.options=this.taskDTO.evaluate.content.split("$")
          }
          if(this.taskDTO.task.type === '调查问卷' && this.taskDTO.investigation.content!=="") {
              this.options=this.taskDTO.evaluate.content.split("$")
          }
      })
  },
  methods: {

      put() {
          var content = ""
          for(var i=0;i<this.contents.length;i++) {
              if (i==0) {
                  content=content + this.contents[i]
              } else {
                  content=content + "$" +this.contents[i]
              }
          }
          if (this.taskDTO.task.type === '评估，评价问卷') {
              this.taskDTO.evaluate.content = content
              this.$http.put("/evaluate", this.taskDTO.evaluate).then(response=>{
                  this.$router.push('/home/result/teacher')
                  this.$message({
                      type: 'success',
                      message: '提交成功'
                  })
              })
          } else {
              this.taskDTO.investigation.content = content
          }
      }

  }
}
</script>
<style>
</style>